<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Minappslistsinfo extends Model
{
    protected $table = 'minapps_lists_info';
    protected $primaryKey = 'id';

    public static function updateMinappsListsInfo($minapps_lists_id,$enterprise_name,$code,$code_type,$legal_persona_wechat,$legal_persona_name,$legal_persona_idcard,$component_phone)
    {
        return self::where("minapps_lists_id",$minapps_lists_id)->update(["enterprise_name"=>$enterprise_name,"code"=>$code,"code_type"=>$code_type,"legal_persona_wechat"=>$legal_persona_wechat,"legal_persona_name"=>$legal_persona_name,"legal_persona_idcard"=>$legal_persona_idcard,"component_phone"=>$component_phone]);
    }

    public static function updateMinappsListsName($minapps_lists_id,$name,$signature)
    {
        return self::where("minapps_lists_id",$minapps_lists_id)->update(["name"=>$name,"signature"=>$signature]);
    }

    public static function updateMinappListInfo($appid,$name,$signature)
    {
        return self::where("appid",$appid)->update(["name"=>$name,"signature"=>$signature]);
    }

    public static function fastRegister($minapps_lists_id,$name,$unique_id,$authorize_url,$appid,$origin_id)
    {
        return self::insert(["minapps_lists_id"=>$minapps_lists_id,"name"=>$name,"unique_id"=>$unique_id,"authorize_url"=>$authorize_url,"appid"=>$appid,"origin_id"=>$origin_id,"created_at"=>time()]);
    }

    public static function fastRegisterWeapp($minapps_lists_id,$name,$enterprise_name,$code_type,$code,$legal_persona_wechat,$legal_persona_name)
    {
        return self::insert(["minapps_lists_id"=>$minapps_lists_id,"name"=>$name,"enterprise_name"=>$enterprise_name,"code_type"=>$code_type,"code"=>$code,"legal_persona_wechat"=>$legal_persona_wechat,"legal_persona_name"=>$legal_persona_name,"created_at"=>time()]);
    }

    public static function fastRegisterPersonWeapp($minapps_lists_id,$name,$enterprise_name,$code_type,$code,$legal_persona_wechat,$legal_persona_name)
    {
        return self::insert(["minapps_lists_id"=>$minapps_lists_id,"name"=>$name,"enterprise_name"=>$enterprise_name,"code_type"=>$code_type,"code"=>$code,"legal_persona_wechat"=>$legal_persona_wechat,"legal_persona_name"=>$legal_persona_name,"created_at"=>time()]);
    }

    public static function getMinappsListsInfo($minapps_lists_id)
    {
        return self::where("minapps_lists_id",$minapps_lists_id)->first();
    }

    public static function updateMinappsListsInfoCategory($minapps_lists_id)
    {
        return self::where("minapps_lists_id",$minapps_lists_id)->update(["category"=>2]);
    }

    public static function updateMinappsListsInfoWxaCommit($minapps_lists_id,$wxa_commit)
    {
        return self::where("minapps_lists_id",$minapps_lists_id)->update(["wxa_commit"=>$wxa_commit]);
    }

    public static function getMinappsListsByOriginalId($original_id)
    {
        return self::where("original_id",$original_id)->first();
    }

    public static function updateMinappsLists($minapps_lists_id,$lists)
    {
        return self::where("minapps_lists_id",$minapps_lists_id)->update($lists);
    }

    public static function getMinappsListsInfoByCode($code,$legal_persona_wechat)
    {
        return self::where("code",$code)->where("legal_persona_wechat",$legal_persona_wechat)->orderBy("id","DESC")->first();
    }

    public static function updateMinappsReleaseMethod($id,$release_method)
    {
        return self::where("id",$id)->update(["release_method"=>$release_method]);
    }

    public static function notifyThirdFasteRegister($id,$appid,$origin_id)
    {
        return self::where("id",$id)->update(["appid"=>$appid,"origin_id"=>$origin_id]);
    }
}